Move focus to the parent if a popover is dismissed
authorMatthias Clasen <mclasen@redhat.com>
Thu, 9 Apr 2020 16:03:23 +0000 (12:03 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Thu, 9 Apr 2020 22:26:31 +0000 (18:26 -0400)
This is better than just dropping focus altogether,
and is expected behavior in most cases.

gtk/gtkwindow.c

index 7e211aaa0f16b3e157fd2733aaab7a31ecf15ff4..707bd84b98d4b4f9a98ba53759ba58176cc1dbb1 100644 (file)
@@ -5740,7 +5740,16 @@ _gtk_window_unset_focus_and_default (GtkWindow *window,
         child = _gtk_widget_get_parent (child);
 
       if (child == widget)
-       gtk_window_set_focus (GTK_WINDOW (window), NULL);
+        {
+          GtkWidget *new_focus;
+
+          if (GTK_IS_NATIVE (widget))
+            new_focus = gtk_widget_get_parent (widget);
+          else
+            new_focus = NULL;
+
+         gtk_window_set_focus (GTK_WINDOW (window), new_focus);
+        }
     }
       
   child = priv->default_widget;